import { AdColumn } from '@/components/AdVxeTable';
import { useI18n } from '@/hooks/web/useI18n';
import { getIoTGatewayProtocolTypeEnumSchema } from '@/enums/iot/ioTGatewayProtocolTypeEnum';
import { getIoTPlatformTypeEnumSchema } from '@/enums/iot/ioTPlatformTypeEnum';

const ioTGatewayProtocolTypeEnumSchema = getIoTGatewayProtocolTypeEnumSchema();
const ioTPlatformTypeEnumSchema = getIoTPlatformTypeEnumSchema();
const { t } = useI18n();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.gateway.setting.nameText'),
    field: 'Name',
    width: 200,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.gateway.setting.protocolTypeText'),
    field: 'ProtocolType',
    width: 90,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'enum',
    enumData: ioTGatewayProtocolTypeEnumSchema,
  },
  {
    title: t('iot.route.gateway.setting.serverText'),
    field: 'Server',
    width: 300,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.gateway.setting.portText'),
    field: 'Port',
    width: 60,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('iot.route.gateway.setting.identityText'),
    field: 'Identity',
    width: 0,
    visible: false,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('iot.route.gateway.setting.passwordText'),
    field: 'Password',
    width: 0,
    visible: false,
    formVisible: true,
    filterable: false,
    dataType: 'password',
  },
  {
    title: t('iot.route.gateway.setting.platformTypeText'),
    field: 'PlatformType',
    width: 150,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'enum',
    enumData: ioTPlatformTypeEnumSchema,
  },
  {
    title: t('iot.route.gateway.setting.whitelistText'),
    field: 'Whitelist',
    width: 0,
    visible: false,
    formVisible: true,
    filterable: false,
    dataType: 'array',
    formSchema: {
      field: 'Whitelist',
      component: 'Input',
      helpMessage: [t('iot.route.gateway.setting.clientIdAndIpText')],
    },
  },
  {
    title: t('iot.route.gateway.setting.blacklistText'),
    field: 'Blacklist',
    width: 0,
    visible: false,
    formVisible: true,
    filterable: false,
    dataType: 'array',
    formSchema: {
      field: 'Blacklist',
      component: 'Input',
      helpMessage: [t('iot.route.gateway.setting.clientIdAndIpText')],
    },
  },
  {
    title: t('iot.route.gateway.setting.enabledText'),
    field: 'Enabled',
    width: 90,
    formVisible: true,
    filterable: true,
    dataType: 'boolean',
    formCustomer: {
      colProps: {
        // span: 12,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 12, // ≥1200px
        xxl: 12, // ≥1600px
        // xxxl: 12, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('iot.route.gateway.setting.timeoutText'),
    field: 'Timeout',
    width: 100,
    formVisible: true,
    required: true,
    filterable: false,
    dataType: 'number',
  },
  {
    title: t('iot.route.gateway.setting.remarkText'),
    field: 'Remark',
    width: 300,
    formVisible: true,
    filterable: true,
    dataType: 'text',
    formCustomer: {
      colProps: {
        // span: 24,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 24, // ≥768px
        lg: 24, // ≥992px
        xl: 24, // ≥1200px
        xxl: 24, // ≥1600px
        // xxxl: 24, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('entity.creationAudited.creatorIdTitle'),
    field: 'CreatorId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.creatorNameTitle'),
    field: 'CreatorName',
    width: 100,
    filterable: true,
    formVisible: true,
    formEditable: false,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.creatorNicknameTitle'),
    field: 'CreatorNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('entity.updateAudited.updaterIdTitle'),
    field: 'UpdaterId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updaterNameTitle'),
    field: 'UpdaterName',
    width: 100,
    filterable: true,
    formVisible: true,
    formEditable: false,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updaterNicknameTitle'),
    field: 'UpdaterNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updatedTimeTitle'),
    field: 'UpdatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
];
